bitkeeper revision 1.1464 (428c995a_kOA184Gp70LrbrBFFfKTA)
authorkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Thu, 19 May 2005 13:49:14 +0000 (13:49 +0000)
committerkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Thu, 19 May 2005 13:49:14 +0000 (13:49 +0000)
Mark all non-RAM pages as I/O holes in the frame_table.
Signed-off-by: Keir Fraser <keir@xensource.com>
xen/arch/x86/mm.c
xen/arch/x86/setup.c

index cd96fec08379fa66bed101fecd560128231823ad..f27508a40d04225b843f9564bafcf1fc119a33dd 100644 (file)
@@ -174,7 +174,7 @@ void arch_init_memory(void)
 {
     extern void subarch_init_memory(struct domain *);
 
-    unsigned long i, j, pfn, nr_pfns;
+    unsigned long i, pfn, rstart_pfn, rend_pfn;
     struct pfn_info *page;
 
     memset(percpu_info, 0, sizeof(percpu_info));
@@ -206,25 +206,26 @@ void arch_init_memory(void)
         page_set_owner(page, dom_io);
     }
  
-    /* Any non-RAM areas in the e820 map are considered to be for I/O. */
-    for ( i = 0; i < e820.nr_map; i++ )
+    /* Any areas not specified as RAM by the e820 map are considered I/O. */
+    for ( i = 0, pfn = 0; i < e820.nr_map; i++ )
     {
-        if ( e820.map[i].type == E820_RAM )
+        if ( e820.map[i].type != E820_RAM )
             continue;
-        pfn = e820.map[i].addr >> PAGE_SHIFT;
-        nr_pfns = (e820.map[i].size +
-                   (e820.map[i].addr & ~PAGE_MASK) +
-                   ~PAGE_MASK) >> PAGE_SHIFT;
-        for ( j = 0; j < nr_pfns; j++ )
+        /* Every page from cursor to start of next RAM region is I/O. */
+        rstart_pfn = PFN_UP(e820.map[i].addr);
+        rend_pfn   = PFN_DOWN(e820.map[i].addr + e820.map[i].size);
+        while ( pfn < rstart_pfn )
         {
-            if ( !pfn_valid(pfn+j) )
-                continue;
-            page = &frame_table[pfn+j];
+            BUG_ON(!pfn_valid(pfn));
+            page = &frame_table[pfn++];
             page->count_info        = PGC_allocated | 1;
             page->u.inuse.type_info = PGT_writable_page | PGT_validated | 1;
             page_set_owner(page, dom_io);
         }
+        /* Skip the RAM region. */
+        pfn = rend_pfn;
     }
+    BUG_ON(pfn != max_page);
 
     subarch_init_memory(dom_xen);
 }
index 644dc7d3e9374026edc27e5623a74f6c897c9694..b30df4de15c3e3e963dca233eaf659f037c84fd3 100644 (file)
@@ -582,8 +582,8 @@ void __init __start_xen(multiboot_info_t *mbi)
         {
             /* Calculate page-frame range, discarding partial frames. */
             unsigned long start, end;
-            start = (e820.map[i].addr + PAGE_SIZE - 1) >> PAGE_SHIFT;
-            end   = (e820.map[i].addr + e820.map[i].size) >> PAGE_SHIFT;
+            start = PFN_UP(e820.map[i].addr);
+            end   = PFN_DOWN(e820.map[i].addr + e820.map[i].size);
             /* Clip the range to above 64MB. */
             if ( end < (64UL << (20-PAGE_SHIFT)) )
                 continue;